"use strict";
const db = uniCloud.database();
const dbCmd = db.command;
exports.main = async (event, context) => {
	//event为客户端上传的参数
	const {
		id
	} = event;

	await db.collection('article').doc(id).update({
		browse_count: dbCmd.inc(1)
	})

	const articleList = await db.collection("article").aggregate()
		.match({
			_id: id
		}).project({
			comments: 0
		}).end()

	//返回数据给客户端
	return {
		code: 0,
		mag: "文章获取成功",
		data: articleList.data[0]
	};
};
